import service from "/@/utils/request";

// 人员
export const useAccessRuleEmployeePageApi = (formData?: object) => {
    return service({
        url: `v0/access/rule/employeePage`,
        method: 'POST',
        data: formData
    });
}

export const useAccessRuleRemoveEmployeeApi = (formData: object) => {
    return service({
        url: `v0/access/rule/removeEmployee`,
        method: 'DELETE',
        data: formData
    });
}
export const useAccessRuleAddEmployeeApi = (formData: object) => {
    return service({
        url: `v0/access/rule/addEmployee`,
        method: 'POST',
        data: formData
    });
}

// 部门
export const useAccessRuleRemoveOrgApi = (formData: object) => {
    return service({
        url: `v0/access/rule/removeOrg`,
        method: 'DELETE',
        data: formData
    });
}
export const useAccessRuleAddOrgApi = (formData: object) => {
    return service({
        url: `v0/access/rule/addOrg`,
        method: 'POST',
        data: formData
    });
}

export const useRuleOrgPageApi = (formData: object) => {
    return service({
        url: `v0/access/rule/orgPage`,
        method: 'POST',
        data: formData
    });
}


// 设备
export const useAccessRuleRemovePointApi = (formData: object) => {
    return service({
        url: `v0/access/rule/removePoint`,
        method: 'DELETE',
        data: formData
    });
}

export const useAccessRulePointPageApi = (formData?: object) => {
    return service({
        url: `v0/access/rule/pointPage`,
        method: 'POST',
        data: formData
    });
}

export const useAccessRuleAddPointApi = (formData: object) => {
    return service({
        url: `v0/access/rule/addPoint`,
        method: 'POST',
        data: formData
    });
}

// 角色
export const useAccessRuleAddRoleApi = (formData: object) => {
    return service({
        url: `v0/access/rule/addRole`,
        method: 'POST',
        data: formData
    });
}
export const useAccessRuleRemoveRoleApi = (formData: object) => {
    return service({
        url: `v0/access/rule/removeRole`,
        method: 'DELETE',
        data: formData
    });
}
export const useAccessRuleRoleListApi = (formData?: object) => {
    return service({
        url: `v0/access/rule/roleList`,
        method: 'POST',
        data: formData
    });
}


export const useAccessRuleQueryApi = (code: string,) => {
    return service({
        url: `v0/access/rule/query`,
        method: 'GET',
        params: { code: code },
    });
}
export const useAccessRulePageApi = (formData?: object) => {
    return service({
        url: `v0/access/rule/page`,
        method: 'POST',
        data: formData
    });
}

export const useAccessRuleCreateApi = (formData: object) => {
    return service({
        url: `v0/access/rule/create`,
        method: 'POST',
        data: formData
    });
}
export const useAccessRuleUpdateApi = (formData: object) => {
    return service({
        url: `v0/access/rule/update`,
        method: 'PUT',
        data: formData
    });
}

export const useAccessRuleDeleteApi = (param: string | string[]) => {
    let arrList: string[] = []

    if (param instanceof Array) {
        arrList = param
    } else {
        arrList.push(param)
    }

    return service({
        url: `v0/access/rule/delete`,
        method: 'DELETE',
        data: { codeList: arrList }
    });
}

export const useAccessRuleListApi = () => {
    return service({
        url: `v0/access/rule/list`,
        method: 'GET'
    });
}


